Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

83
Visualizações
I Need to use variables in Cypress Cucumber Tests [still open]

I need to work on some variables in my project its necessary. And as you know it is very difficult in cypress because of cypress's own promise-like chain system. Because of that, some variables can come "unidentified" so tests will not pass.

Before starting edit: we are using cucumber but we are not giving para-metered step definitions because tests are dynamic and they will run on CI. .then() is not working because there are so many test steps that are using variables. also, I tried "background" keyword on cucumber and that didn't work.

This is the standard problem, I need a solution how can I force some tests to wait for variables to be filled and ready to read.

I think maybe event listeners can be work but I am not sure, really I don't have any idea about that situation.

Anyone can help me with that problem? Or anyone has an idea how can I use event listener in cucumber test cases? Thank you so much about reading my difficult question.

            var tmr
            // set variables
            localStorage.setItem('work_order_id', 10060);
            localStorage.setItem('current_step', 0);
            var taskInProggress=false

            function run_next_test() {
            
                taskInProggress=true
                let currentStep=localStorage.getItem('current_step')*1;


                console.log("Running task ", currentStep);      
                switch (currentStep) {
                    case 0 : 
                        //runStep0().then(response=>{
                        taskInProggress=false
                        localStorage.setItem('current_step', currentStep+1);
                        //});
                    /*
                      test
                    */
                    break;
                    default: // for work empty
                        taskInProggress=false
                        localStorage.setItem('current_step', currentStep+1);
                        break
                }
            }

            function step_listener(){
                let currentStep=localStorage.getItem('current_step');
                console.log("listen...");
                if (taskInProggress)  {
                    console.log("Step ",currentStep," still in progress ...");
                    tmr = setTimeout(step_listener, 1000);  
                    return
                }



                if (currentStep<10){
                    currentStep++;
                    run_next_test(currentStep)
                    tmr = setTimeout(step_listener, 1000);  
                }else{
                    clearTimeout(tmr);
                    console.log("Test finished")
                }

            
            }

            step_listener();

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda